<template>
    <a-card :bordered="false">
      <div>
        <a-table
          ref="table"
          size="middle"
          :scroll="{x:true}"
          bordered
          rowKey="id"
          :columns="columns"
          :dataSource="dataSource"
          :pagination="ipagination"
          :loading="loading"
          class="j-table-force-nowrap"
          @change="handleTableChange">
          <template slot="htmlSlot" slot-scope="text">
            <div v-html="text"></div>
          </template>
          <template slot="imgSlot" slot-scope="text,record">
            <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
            <img v-else :src="getImgView(text)" :preview="record.id" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
          </template>
          <template slot="fileSlot" slot-scope="text">
            <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
            <a-button
              v-else
              :ghost="true"
              type="primary"
              icon="download"
              size="small"
              @click="downloadFile(text)">
              下载
            </a-button>
          </template>
          <span slot="status" slot-scope="text, record, index">
            <a-tag color="pink" v-if="text==0">失效</a-tag>
            <a-tag color="#87d068" v-if="text==1" >正常</a-tag>
        </span>
          <span slot="isBuy" slot-scope="text, record, index">
            <span style='color: red' v-if='record.isBuy==1'>已申购</span>
              <span v-if='record.isBuy==0' >未申购</span>
          </span>

          <span slot="action" slot-scope="text, record">

        </span>
        </a-table>
      </div>
    </a-card>
</template>

<script>

import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { deleteAction, getAction } from '@api/manage'


export default {
  name: 'UserhomeInviterListModal',
  mixins:[JeecgListMixin, mixinDevice],
  props: {
    inviterId: {
      type: Number,
      default: ''
    },
  },
    components: {},
    data() {
      return {
        description: '银行卡列表',
        // 表头
        columns: [
          {
            title: '用户id',
            align: "center",
            dataIndex: 'id'
          },
          {
            title: '用户邮箱',
            align: "center",
            dataIndex: 'username'
          },
          {
            title: '用户手机',
            align: "center",
            dataIndex: 'phone'
          },
          {
            title: '用户状态',
            align: "center",
            dataIndex: 'status',
            scopedSlots: { customRender: 'status' }
          },
          {
            title: '用户类型',
            align: "center",
            dataIndex: 'isBuy',
            scopedSlots: { customRender: 'isBuy' }
          },
          {
            title: '佣金余额(元)',
            align: "center",
            dataIndex: 'money'
          },
          {
            title: '账号余额(元)',
            align: "center",
            dataIndex: 'fmoney'
          },
          {
            title: '申购基金总额(元)',
            align: "center",
            dataIndex: 'fundMoney'
          },
          {
            title: '注册时间',
            align: "center",
            dataIndex: 'createTime',
            customRender: function(text) {
              return !text ? "" : (text.length > 10 ? text.substr(0, 10) : text)
            }
          }
        ],
        url: {
          list: "/gongqiang/userhome/list",
        },
        title: "银行卡列表",
        dictOptions: {},
        superFieldList: [],
      }
    },
    created() {
      this.getSuperFieldList();
    },
    computed: {
      importExcelUrl: function() {
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      initDictConfig() {
      },
      loadData(arg) {
        if (!this.url.list) {
          this.$message.error("请设置url.list属性!")
          return
        }
        if (this.inviterId == null || this.inviterId == "") {
          return
        }
        this.queryParam.inviterId = this.inviterId;
        //加载数据 若传入参数1则加载第一页的内容
        if (arg === 1) {
          this.ipagination.current = 1;
        }
        var params = this.getQueryParams();//查询条件
        this.loading = true;
        getAction(this.url.list, params).then((res) => {
          if (res.success) {
            //update-begin---author:zhangyafei    Date:20201118  for：适配不分页的数据列表------------
            this.dataSource = res.result.records || res.result;
            if (res.result.total) {
              this.ipagination.total = res.result.total;
            } else {
              this.ipagination.total = 0;
            }
            //update-end---author:zhangyafei    Date:20201118  for：适配不分页的数据列表------------
          } else {
            this.$message.warning(res.message)
          }
        }).finally(() => {
          this.loading = false
        })
      },
      getSuperFieldList() {
        let fieldList = [];

        this.superFieldList = fieldList
      }
    }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>